<?php
/**
 * Created by PhpStorm.
 * User: leo
 * Date: 2017/8/21
 * Time: 20:06
 */

namespace app\admin\controller\order;

use app\admin\model\Order as OrderModel;
use app\common\controller\Backend;
use app\common\model\Category as CategoryModel;
use think\Session;

/**
 * Class Order
 * @package app\admin\controller\staff
 * 此类为我的面试控制器
 */
class Worklist extends Backend
{
	protected $model = null;
	
	public function _initialize()
	{
		parent::_initialize();
		$this->model = model('Worklog');
		$facetypelist = db('facetype')->select();
		$serverdaytpyelist=db('serverdays')->select();
		foreach ($serverdaytpyelist as $key=>$value){
			$daydata[$value['id']]=$value['server_days'];
		}
		$this->view->assign('daylist',$daydata);
		$this->view->assign('facetypelist', $facetypelist);
	}
	
	/**
	 * 此函数为显示为员工的工作列表
	 */
	public function index()
	{
		$this->view->assign('staffid',$_GET['staffid']);
		if ($this->request->isAjax()) {
			list($where, $sort, $order, $offset, $limit) = $this->buildparams(NULL);
			$total = $this->model->with('order')
				->where($where)->where('staff_id', $_GET['staffid'])
				->order($sort, $order)
				->count();
			$list = $this->model->with('order')
				->where($where)->where('staff_id', $_GET['staffid'])
				->order($sort, $order)
				->limit($offset, $limit)
				->select();
			$result = array("total" => $total, "rows" => $list);
			return json($result);
		}
		return $this->view->fetch();
	}
}